//
//  LcPreconditions.h
//  18Birdies
//
//  Created by Lc on 15/3/24.
//  Copyright (c) 2015年 Lc. All rights reserved.
//

#import <Foundation/Foundation.h>

#define LC_CHECK_NOT_NULL(object)            \
  [LcPreconditions checkNotNull:object       \
                           file:__FILE__     \
                         method:__FUNCTION__ \
                           line:__LINE__]
#define LC_CHECK_NOT_EMPTY(object)            \
  [LcPreconditions checkNotEmpty:object       \
                            file:__FILE__     \
                          method:__FUNCTION__ \
                            line:__LINE__]
#define LC_CHECK_TRUE(condition)          \
  [LcPreconditions checkTrue:condition    \
                        file:__FILE__     \
                      method:__FUNCTION__ \
                        line:__LINE__]
#define LC_CHECK_FALSE(condition)          \
  [LcPreconditions checkFalse:condition    \
                         file:__FILE__     \
                       method:__FUNCTION__ \
                         line:__LINE__]
#define LC_FAIL() \
  [LcPreconditions fail:nil file:__FILE__ method:__FUNCTION__ line:__LINE__]
#define LC_DEBUG_FAIL()                   \
  [LcPreconditions debugFail:nil          \
                        file:__FILE__     \
                      method:__FUNCTION__ \
                        line:__LINE__]
#define LC_CHECK_IS_MAIN_THREAD()                 \
  [LcPreconditions checkIsMainThread:nil          \
                                file:__FILE__     \
                              method:__FUNCTION__ \
                                line:__LINE__]
#define LC_CHECK_ELEMENT_TYPE(collection, elementClazz, allowNullElement) \
  [LcPreconditions checkCollection:collection                             \
                  withElementClazz:elementClazz                           \
               andAllowNullElement:allowNullElement                       \
                              file:__FILE__                               \
                            method:__FUNCTION__                           \
                              line:__LINE__]

@interface LcPreconditions : NSObject

+ (void)checkNotNull:(id)object
                file:(const char*)file
              method:(const char*)method
                line:(long)line;
+ (void)checkNotEmpty:(NSObject*)object
                 file:(const char*)file
               method:(const char*)method
                 line:(long)line;
+ (void)checkTrue:(BOOL)condition
             file:(const char*)file
           method:(const char*)method
             line:(long)line;
+ (void)checkFalse:(BOOL)condition
              file:(const char*)file
            method:(const char*)method
              line:(long)line;
+ (void)fail:(NSString*)reason
        file:(const char*)file
      method:(const char*)method
        line:(long)line;
+ (void)debugFail:(NSString*)reason
             file:(const char*)file
           method:(const char*)method
             line:(long)line;
+ (void)checkIsMainThread:(NSString*)reason
                     file:(const char*)file
                   method:(const char*)method
                     line:(long)line;
+ (void)checkCollection:(id)collection
       withElementClazz:(Class)elementClazz
    andAllowNullElement:(BOOL)allowNullElement
                   file:(const char*)file
                 method:(const char*)method
                   line:(long)line;

@end
